<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>Dependency Injection</title>
</head>
<body>
<p>See Martin Fowlers's <a href="http://www.martinfowler.com/articles/injection.html">Inversion
    of Control Containers and the Dependency Injection patten</a> article
    from 2003 for a thorough description. Surely everyone has read this by
    now?</p>

<p>Very
    quickly: Dependency Injection is where components are given their
    dependencies through their constructors, methods, or directly into
    fields. Those components do not get their dependencies
    themselves, or instantiate them directly. This is very much
    related to the encompassing design principle <a href="inversion-of-control.html">Inversion of Control</a>.
</p>

<h2>Different types of Dependency Injection supported by
    PicoContainer </h2>

<p>PicoContainer
    supports multiple ways to specify the injection of dependencies into
    components. Constructor injection (listed first) is the
    recomended idiom for PicoContainer. Other types leverage
    fields
    and methods. Variations of the method types, can follow a
    naming
    convention or be marked with an annotation. Dependencies for
    those could be populated one by one, or all in one method call. Indeed
    components could be populated with combinations of Constructor, Method
    and Field Injection.</p>
<table width="70%" border="1">
  <tr>
    <td colspan="2"><strong>Regular Injection Types</strong></td>
  </tr>
  <tr>
    <td><a href="constructor-injection.html">Constructor Injection</a></td>
    <td> Where a the constructor of a class is used to pass dependencies into it.</td>
  </tr>
  <tr>
    <td><a href="setter-injection.html">Setter Injection</a></td>
    <td>Multiple Setter methods on the class are used to pass dependencies in. </td>
  </tr>
  <tr>
    <td>Annotated Method Injection</td>
    <td>Methods are marked with an annotation to indicate that they should be used for injecting dependencies</td>
  </tr>
  <tr>
    <td>Field Injection</td>
    <td>Fields are injected into for dependencies</td>
  </tr>
  <tr>
    <td>Annotated Field Injection</td>
    <td>Fields are marked with an annotation to indicate that they should be injected into</td>
  </tr>
  <tr>
    <td>Named Field Injection</td>
    <td>Fields of a certain name should be injected into</td>
  </tr>
  <tr>
    <td>Named Method Injection</td>
    <td>If method names match other component names, injection happens</td>
  </tr>
  <tr>
    <td>Typed Field Injection</td>
    <td>Fields of a certain type should be injected into</td>
  </tr>
  <tr>
    <td colspan="2"><strong>Irregular Injection Types</strong></td>
  </tr>
  <tr>
    <td>Adapting Injection</td>
    <td>Adapting Injection finds which types of injection are pertinant to a component and builds an injector that fits it precisely. This is the default type of injection for DefaultPicoContainer</td>
  </tr>
  <tr>
    <td>Multi Injection</td>
    <td>Multiple Injection points in order: Constructor, Annotated Methods and then finally Annotated Fields</td>
  </tr>
  <tr>
    <td> Composite Injection</td>
    <td>As Multi, but an open list of Injection types that makes most sense for your components.</td>
  </tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3>Where Next?</h3>
<span class="callout">
The&nbsp;<a href="behaviors.html">Modifying Behaviors</a>
page outlines the adding of behaviors to components</span>
</body>
</html>